<?php

/**
 * Form for allocate child with parents
 */
class Application_Form_AttachParent extends Zend_Form
{

    public function init()
    {
	$this->setMethod('post');

	// Element parent_id
	$this->addElement('select', 'parent_id', array(
	    'label' => 'Elternteil',
	    'required' => true,
	    'multiOptions' => $this->createSelectFildsFromParents()
	));

    }

    /**
     * Converts a child array to select fields
     */
    function createSelectFildsFromParents()
    {
	$modelParents = new Model_Parent;
	$parents = $modelParents->listAll();

	$selectParents = array();
	foreach ($parents as $parent)
	{
	    $selectParents[$parent['id']] = $parent['surname'] . ", " . $parent['forename'];
	}
	return $selectParents;
    }

}
